﻿using System;
using System.IO;
using System.Data;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using LEDDataBase;
using LEDHelper;
using System.Windows.Interop;
using System.Windows.Shapes;
namespace LEDManager
{
    public partial class LEDUnit2
    {
        private void LED_FastenProgram()
        {
            try
            {
                m_data.Reset();
                #region=============
                DataRow dwContent;
                FontDescriptor lpFont;
                int method, speed, transparent;
                string fontID;
                dwProg = null;
                int nScreenType = LEDAPI.SCREEN_COLOR;
                var query = from dwPr in m_data.LEDDatas.PROGRAM.AsEnumerable()
                            where dwPr["PRPROGRAMID"].ToString() == progID
                            select dwPr;
                foreach (DataRow dwTemp in query)
                {
                    dwProg = dwTemp;
                }
                if (dwProg == null)
                    return;
                #endregion
                string filter = "LFSYSTEM='" + system + "' and LFLEDID='" + ledid + "' and LFPROGRAMID='" + progID + "'";
                DataRow[] rowsl = m_data.LEDDatas.LEAF.Select(filter);
                //MessageBox.Show(filter + rowsl.Length);
                DataRow[] rowsd;
                if (rowsl.Length == 0)
                    return;
                nScreenType = System.Convert.ToInt32(dwProg["PRSCREENTYPE"].ToString());
                PerformCommand("LED_Open", nScreenType, nWidth, nHeight, LEDAPI.ROOT_DOWNLOAD);
                string processlefid = "";
                foreach (DataRow dwLf in rowsl)
                {

                    string lefid = dwLf["LFLEAFID"].ToString();
                    if (processlefid.Contains(lefid + ";"))
                        continue;
                    processlefid += lefid + ";";
                    int lDisplayTime = System.Convert.ToInt32(dwLf["LFDURATION"].ToString());
                    filter = "LDLEAFID='" + lefid + "'";
                    PerformCommand("AddLeaf", lDisplayTime, "");
                    rowsd = m_data.LEDDatas.LEAFDETAIL.Select(filter);
                    foreach (DataRow dwLd in rowsd)
                    {
                        string ctype = dwLd["LDCONTENTTYPE"].ToString();
                        string cid = dwLd["LDCONTENTID"].ToString();
                        #region=====LEDBlock========
                        int LDLTOPX = System.Convert.ToInt32(dwLd["LDLTOPX"].ToString());
                        int LDLTOPY = System.Convert.ToInt32(dwLd["LDLTOPY"].ToString());
                        int LDLBOTTOMX = System.Convert.ToInt32(dwLd["LDLBOTTOMX"].ToString());
                        int LDLBOTTOMY = System.Convert.ToInt32(dwLd["LDLBOTTOMY"].ToString());
                        int LDRTOPX = System.Convert.ToInt32(dwLd["LDRTOPX"].ToString());
                        int LDRTOPY = System.Convert.ToInt32(dwLd["LDRTOPY"].ToString());
                        int LDRBOTTOMX = System.Convert.ToInt32(dwLd["LDRBOTTOMX"].ToString());
                        int LDRBOTTOMY = System.Convert.ToInt32(dwLd["LDRBOTTOMY"].ToString());

                        LEDBlock rect = new LEDBlock();
                        rect.nStartX = LDLTOPX;
                        rect.nStartY = LDLTOPY;
                        rect.nWidth = LDRTOPX - LDLTOPX;
                        rect.nHeight = LDLBOTTOMY - LDLTOPY;
                        #endregion
                        switch (ctype)
                        {
                            case "CTEXT":
                                dwContent = m_data.GetContent("CTEXT", cid);
                                string szText = dwContent["CTCONTENT"].ToString();
                                method = System.Convert.ToInt32(dwContent["EFFECT"].ToString());
                                speed = System.Convert.ToInt32(dwContent["SPEED"].ToString());
                                transparent = System.Convert.ToInt32(dwContent["TRANSPARENT"].ToString());
                                fontID = dwContent["FONTID"].ToString();
                                dwFont = m_data.GetContent("FONTTABLE", fontID);
                                lpFont = new FontDescriptor();
                                lpFont.szFontName = dwFont["CFFONTNAME"].ToString();
                                lpFont.lFontSize = System.Convert.ToInt32(dwFont["CFFONTSIZE"].ToString());
                                lpFont.lFontColor = System.Convert.ToInt32(dwFont["CFCOLOR"].ToString());
                                PerformCommand("AddText", szText, rect, lpFont, method, speed, transparent);
                                break;
                            case "CPICTURE":
                                dwContent = m_data.GetContent("CPICTURE", cid);
                                string szBmpFile = dwContent["CPPICTUREFILE"].ToString();
                                method = System.Convert.ToInt32(dwContent["EFFECT"].ToString());
                                speed = System.Convert.ToInt32(dwContent["SPEED"].ToString());
                                transparent = System.Convert.ToInt32(dwContent["TRANSPARENT"].ToString());
                                LEDBlock destRect = new LEDBlock();
                                LEDBlock sourceRect = new LEDBlock();
                                sourceRect.nStartX = 0;
                                sourceRect.nStartY = 0;
                                sourceRect.nWidth = System.Convert.ToInt32(dwContent["CPWIDTH"].ToString());
                                sourceRect.nHeight = System.Convert.ToInt32(dwContent["CPHEIGHT"].ToString());
                                destRect.nStartX = rect.nStartX;
                                destRect.nStartY = rect.nStartY;
                                destRect.nWidth = rect.nWidth;
                                destRect.nHeight = rect.nHeight;
                                PerformCommand("AddWindow", szBmpFile, destRect, sourceRect, method, speed, transparent);
                                break;
                            case "CCLOCK":
                                dwContent = m_data.GetContent("CCLOCK", cid);
                                ClockDescriptor lpClock = new ClockDescriptor();
                                fontID = dwContent["FONTID"].ToString();
                                dwFont = m_data.GetContent("FONTTABLE", fontID);
                                lpFont = new FontDescriptor();
                                lpFont.szFontName = dwFont["CFFONTNAME"].ToString();
                                lpFont.lFontSize = System.Convert.ToInt32(dwFont["CFFONTSIZE"].ToString());
                                lpFont.lFontColor = System.Convert.ToInt32(dwFont["CFCOLOR"].ToString());
                                method = System.Convert.ToInt32(dwContent["EFFECT"].ToString());
                                speed = System.Convert.ToInt32(dwContent["SPEED"].ToString());
                                transparent = System.Convert.ToInt32(dwContent["TRANSPARENT"].ToString());
                                PerformCommand("AddDateTime", rect, lpClock, lpFont, method, speed, transparent);
                                break;
                            default:
                                break;
                        }
                    }
                }
                PerformCommand("LED_EndProgram");
                PerformCommand("LED_SendToScreen");
                //初始化一个节目表
                //在编辑过程中添加，建立节目
                //
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void LED_EndProgram()
        {
            try
            {
                m_data.Save();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void ConverBmpToFixedProgram(string szBmpFile)
        {
            try
            {
                int nScreenType = LEDAPI.SCREEN_COLOR;
                PerformCommand("LED_Open", nScreenType, nWidth, nHeight, LEDAPI.ROOT_DOWNLOAD);
                PerformCommand("AddLeaf", 10000, "");
                int method = 1;
                int speed = 1;
                int transparent = 1;
                LEDBlock destRect = new LEDBlock();
                LEDBlock sourceRect = new LEDBlock();
                sourceRect.nStartX = 0;
                sourceRect.nStartY = 0;
                sourceRect.nWidth = nWidth;
                sourceRect.nHeight = nHeight;
                destRect.nStartX = 0;
                destRect.nStartY = 0;
                destRect.nWidth = nWidth;
                destRect.nHeight = nHeight;
                PerformCommand("AddWindow", szBmpFile, destRect, sourceRect, method, speed, transparent);
                PerformCommand("LED_EndProgram");
                PerformCommand("LED_SendToScreen");
                PerformCommand("LED_FastenProgram");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public object Parse2(Int32 K)
        {
            object result = null;
            TNotifyParam notify = new TNotifyParam();
            if (K >= 0)
            {
                LED_GetNotifyParam(ref notify, K);

                if (notify.notify == LM_TIMEOUT)
                {
                    result = "命令执行超时";
                }
                else if (notify.notify == LM_TX_COMPLETE)
                {
                    if (notify.result == RESULT_FLASH)
                    {
                        result = "数据传送完成，正在写入Flash";
                    }
                    else
                    {
                        result = "数据传送完成";
                    }
                }
                else
                    if (notify.notify == LM_NOTIFY)
                    {
                        if (notify.result == NOTIFY_GET_PLAY_BUFFER)
                        {
                            string file="D:\\SXDFile\\Temp\\play.dat";
                            if (System.IO.File.Exists(file))
                            { 
                                System.IO.File.Delete(file);

                            }
                            LED_PreviewFile(128, 64, file);
                        }
                    }
                    if (notify.notify == LM_RESPOND)
                {
                    if (notify.command == PKC_GET_POWER)
                    {
                        if (notify.status == LED_POWER_ON) result = "读取电源状态完成，当前为电源开启状态";
                        else if (notify.status == LED_POWER_OFF) result = "读取电源状态完成，当前为电源关闭状态";
                    }
                    else if (notify.command == PKC_SET_POWER)
                    {
                        if (notify.result == 99) result = "当前为定时开关屏模式";
                        else if (notify.status == LED_POWER_ON) result = "设置电源状态完成，当前为电源开启状态";
                        else result = "设置电源状态完成，当前为电源关闭状态";
                    }
                    else if (notify.command == PKC_GET_BRIGHT)
                    {
                        result = string.Format("读取亮度完成，当前亮度={0:D}", notify.status);
                    }
                    else if (notify.command == PKC_SET_BRIGHT)
                    {
                        if (notify.result == 99) result = "当前为定时亮度调节模式";
                        else result = string.Format("设置亮度完成，当前亮度={0:D}", notify.status);
                    }
                    else if (notify.command == PKC_ADJUST_TIME)
                    {
                        result = "校正显示屏时间完成";
                    }
                }
            }
            else if (K == R_DEVICE_INVALID) result = "打开通讯设备失败(串口不存在、或者串口已被占用、或者网络端口被占用)";
            else if (K == R_DEVICE_BUSY) result = "设备忙，正在通讯中...";
            return result;
        }
        public object PerformCommand(string command,
            object p1 = null, object p2 = null, object p3 = null, object p4 = null, object p5 = null, object p6 = null, object p7 = null, object p8 = null, object p9 = null, object p10 = null,
            object p11 = null, object p12 = null, object p13 = null, object p14 = null, object p15 = null, object p16 = null, object p17 = null, object p18 = null, object p19 = null, object p20 = null,
            object p21 = null, object p22 = null, object p23 = null, object p24 = null, object p25 = null, object p26 = null, object p27 = null, object p28 = null, object p29 = null, object p30 = null)
        {
            object result = 0;
            string szBmpFile;
            int nScreenType = LEDAPI.SCREEN_COLOR;
            Int32 nSpeed = 1;
            Int32 lTrasnparent = 1;
            Int32 nEffectType = 1;
            Int32 method = nEffectType;
            Int32 speed = nSpeed;
            Int32 transparent = lTrasnparent;
            int playtype = LEDAPI.ROOT_PLAY;
            LEDBlock rect = new LEDBlock();
            SRECT rectx = new SRECT();
            FontDescriptor lpFont = new FontDescriptor();
            LEDBlock destRect = new LEDBlock();
            LEDBlock sourceRect = new LEDBlock();
            int iDisplaytime = 100;
            string filename = "", profile, content;
            Int32 RootType = 0;
            Int32 ColorMode = 0;
            Int32 survive = 0;
            Int32 ActionMode = 0;
            Int32 ChapterIndex = 0;
            UInt32 time = 0;
            ushort wait = 0;
            ushort num = 0;
            string text = "";
            Int32 RegionIndex = 0;
            Int32 LeafIndex = 0;
            Int32 ObjectIndex = 0;
            Int32 left = 0;
            Int32 top = 0;
            Int32 border = 0;
            Int32 vertical = 0;
            string fontname = "";
            Int32 fontsize = 12;
            Int32 fontcolor = 12;
            Int32 fontstyle = 1;
            Int32 countertype = 0;
            Int32 year_offset = 0;
            Int32 month_offset = 0;
            Int32 day_offset = 0;
            Int32 sec_offset = 0;
            string format = "";
            Int32 serverindex = 0;
            Int32 localport = 0;
            Int32 listaddr = 0;
            Int32 count = 0;
            Int32 index = 0;
            Int32 iValue = 1;
            ushort kind = 0;
            ushort week = 0;
            Int32 btime = 0;
            Int32 bdate = 0;
            Int32 stime = 0;
            Int32 sdate = 0;
            Int32 etime = 0;
            Int32 edate = 0;
            TTimeStamp fromtime;
            TTimeStamp totime;
            TTimeStamp basetime;
            Int32 step = 0;
            Int32 offset;
            UInt32 cdotvisible, cdotcolor, bkcolor, bordercolor, borderwidth, adotcolor, bdotcolor, hourcolor, minutecolor, secondcolor;
            Int32 src_width, src_height, stretch, cdotwidth, bordershape, adotwidth, dotradius, badotwidth, bdotwidth, hourwidth, minutewidth, secondwidth;
            UInt32 dc;
            Int32 flag, alignment, fontset, color, inmethod, autofitsize, wordwrap, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime, verticalspace, horizontalfit;
            try
            {
                switch (command)
                {
                    case "LED_ResetDisplay":
                        result = Parse2(LED_ResetDisplay(ref sender));
                        break;
                    case "LED_Reboot":
                        result = Parse2(LED_Reboot(ref sender));
                        break;
                    case "LED_GetTemperatureHumidity":
                        result = Parse2(LED_GetTemperatureHumidity(ref sender));
                        break;
                    case "LED_SetPower":
                        iValue = System.Convert.ToInt32(p1);
                        int iOutpuIP = System.Convert.ToInt32(p2);
                        result = Parse2(LED_SetPower(ref sender, iValue));
                        if (iOutpuIP == 1)
                        {
                            result = "IP:" + rmtHost + " 端口:" + rmtPort;
                        }
                        break;
                    case "LED_GetPower":
                        result = Parse2(LED_GetPower(ref sender));
                        break;
                    case "LED_SetBright":
                        iValue = System.Convert.ToInt32(p1);
                        result = Parse2(LED_SetBright(ref sender, iValue));
                        break;
                    case "LED_GetBright":
                        result = Parse2(LED_GetBright(ref sender));
                        break;
                    case "LED_AdjustTime":
                        result = LED_AdjustTime(ref sender);
                        break;
                    case "LED_AdjustTimeEx":
                        #region==============
                        TSystemTime Ttime = new TSystemTime();
                        DateTime date = System.DateTime.Now;
                        Ttime.wYear = (ushort)date.Year;
                        Ttime.wMonth = (ushort)date.Month;
                        Ttime.wDay = (ushort)date.Day;
                        Ttime.wDayOfWeek = (ushort)date.DayOfWeek;
                        Ttime.wHour = (ushort)date.Hour;
                        Ttime.wMinute = (ushort)date.Minute;
                        Ttime.wSecond = (ushort)date.Second;
                        Ttime.wMilliseconds = (ushort)date.Millisecond;
                        result = Parse2(LED_AdjustTimeEx(ref sender, ref Ttime));
                        break;
                        #endregion
                    case "LED_SendToScreen":
                        index = System.Convert.ToInt32(p1);
                        int zip= System.Convert.ToInt32(p2);
                        if (zip == 1)
                        {
                            LED_Compress(index);
                        }
                        result = Parse2(LED_SendToScreen(ref sender, index));
                        break;
                    case "LED_UDP_SenderParam":
                        #region==============
                        param_index = System.Convert.ToInt32(p1);
                        localport = System.Convert.ToInt32(p2);
                        rmtHost = System.Convert.ToString(p3);
                        rmtPort = System.Convert.ToUInt16(p4);
                        address = System.Convert.ToInt32(p5);
                        notifymode = System.Convert.ToInt32(p6);
                        wmhandle = System.Convert.ToInt32(p7);
                        wmmessage = System.Convert.ToInt32(p8);
                        result = Parse2(LED_UDP_SenderParam(param_index, localport, rmtHost, rmtPort, address, notifymode, wmhandle, wmmessage));
                        break;
                        #endregion
                    case "LED_COM_SenderParam":
                        #region==============
                        param_index = System.Convert.ToInt32(p1);
                        comPort = System.Convert.ToUInt16(p2);
                        baudrate = System.Convert.ToInt32(p3);
                        address = System.Convert.ToInt32(p4);
                        notifymode = System.Convert.ToInt32(p5);
                        wmhandle = System.Convert.ToInt32(p6);
                        wmmessage = System.Convert.ToInt32(p7);
                        result = Parse2(LED_COM_SenderParam(param_index, comPort, baudrate, address, notifymode, wmhandle, wmmessage));
                        break;
                        #endregion
                    case "LED_SendToScreen2":
                        #region======================
                        param_index = System.Convert.ToInt32(p1);
                        index = System.Convert.ToInt32(p2);
                        result = Parse2(LED_SendToScreen2(param_index, index));
                        break;
                        #endregion
                    case "LED_PreviewFile":
                        width = System.Convert.ToInt32(p1);
                        height = System.Convert.ToInt32(p2);
                        string previewfile = System.Convert.ToString(p3);
                        LED_PreviewFile(width, height, previewfile);
                        break;
                    case "LED_Compress":
                        #region======================
                        param_index = System.Convert.ToInt32(p1);
                        result = LED_Compress(param_index);
                        break;
                        #endregion
                    case "LED_Cache_GetBoardParam":
                        result = Parse2(LED_Cache_GetBoardParam(ref sender));
                        break;
                    case "LED_Cache_GetBoardParam2":
                        #region======================
                        param_index = System.Convert.ToInt32(p1);
                        result = Parse2(LED_Cache_GetBoardParam2(param_index));
                        break;
                        #endregion
                    case "LED_Cache_SetBoardParam":
                        result = Parse2(LED_Cache_SetBoardParam(ref sender));
                        break;
                    case "LED_GetPlayContent":
                        //LED_GetPlayContent
                        //result = Parse2(LED_GetPlayContent(ref sender));
                        result = LED_GetPlayContent(ref sender);
                        break;
                    case "LED_SetRotate":
                        #region==============
                        Int32 rotate = System.Convert.ToInt32(p1);
                        width = System.Convert.ToInt32(p2);
                        height = System.Convert.ToInt32(p3);
                        result = SetRotate(rotate, width, height);
                        break;
                        #endregion
                    case "LED_MakeFromVsqFile":
                        #region==============
                        filename = System.Convert.ToString(p1);
                        RootType = System.Convert.ToInt32(p2);
                        ColorMode = System.Convert.ToInt32(p3);
                        survive = System.Convert.ToInt32(p4);
                        result = MakeFromVsqFile(filename, RootType, ColorMode, survive);
                        break;
                        #endregion
                    case "LED_MakeRoot":
                        #region======================
                        RootType = GetRootType((string)p1);
                        ColorMode = GetColorMode((string)p2);
                        survive = GetSurvive((string)p3);
                        result = MakeRoot(RootType, ColorMode, survive);
                        break;
                        #endregion
                    case "LED_MakeObject":
                        #region======================
                        ChapterIndex = System.Convert.ToInt32(p3);
                        RegionIndex = System.Convert.ToInt32(p4);
                        LeafIndex = System.Convert.ToInt32(p5);
                        ObjectIndex = System.Convert.ToInt32(p6);
                        RootType = GetRootType((string)p1);
                        ActionMode = GetActoonMode((string)p2);
                        ColorMode = GetColorMode((string)p7);
                        result = MakeObject(RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ObjectIndex, ColorMode);
                        break;
                        #endregion
                    case "LED_MakeChapter":
                        #region=======================
                        RootType = GetRootType((string)p1);
                        ActionMode = GetActoonMode((string)p2);
                        ChapterIndex = System.Convert.ToInt32(p3);
                        ColorMode = GetColorMode((string)p4);
                        time = System.Convert.ToUInt32(p5);
                        wait = (ushort)GetWaitType((string)p6);                        
                        result = MakeChapter(RootType, ActionMode, ChapterIndex, ColorMode, time, wait);
                        break;
                        #endregion
                    case "LED_MakeRegion":
                        #region==============
                        RootType = System.Convert.ToInt32(p1);
                        ActionMode = System.Convert.ToInt32(p2);
                        ChapterIndex = System.Convert.ToInt32(p3);
                        RegionIndex = System.Convert.ToInt32(p4);
                        ColorMode = System.Convert.ToInt32(p5);
                        left = System.Convert.ToInt32(p6);
                        top = System.Convert.ToInt32(p7);
                        width = System.Convert.ToInt32(p8);
                        height = System.Convert.ToInt32(p9);
                        border = System.Convert.ToInt32(p10);
                        result = MakeRegion(RootType, ActionMode, ChapterIndex, RegionIndex, ColorMode, left, top, width, height, border);

                        break;
                        #endregion
                    case "LED_MakeLeaf":
                        #region==============
                        RootType = GetRootType((string)p1);
                        ActionMode = GetActoonMode((string)p2);
                        ChapterIndex = System.Convert.ToInt32(p3);
                        RegionIndex = System.Convert.ToInt32(p4);
                        LeafIndex = System.Convert.ToInt32(p5);
                        ColorMode = GetColorMode((string)p6);
                        time = System.Convert.ToUInt32(p7);
                        wait = (ushort)GetWaitType((string)p8);
                        result = MakeLeaf(RootType, ActionMode, ChapterIndex, RegionIndex, LeafIndex, ColorMode, time, wait);
                        break;
                        #endregion
                    case "LED_AddChapter":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        time = System.Convert.ToUInt32(p2);
                        switch ((string)p3)
                        {
                            case "WAIT_CHILD":
                                wait = WAIT_CHILD;
                                break;
                            case "WAIT_USE_TIME":
                                wait = WAIT_USE_TIME;
                                break;
                            default:
                                wait = WAIT_USE_TIME;
                                break;
                        }//WAIT_CHILD WAIT_USE_TIME
                        result = AddChapter(num, time, wait);
                        break;
                        #endregion
                    case "LED_AddChapterEx":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        time = System.Convert.ToUInt32(p2);
                        wait =(ushort) GetWaitType((string)p3);
                        kind = System.Convert.ToUInt16(p4);
                        week = System.Convert.ToUInt16(p5);
                        stime = System.Convert.ToInt32(p6);
                        sdate = System.Convert.ToInt32(p7);
                        etime = System.Convert.ToInt32(p8);
                        edate = System.Convert.ToInt32(p9);
                        fromtime = new TTimeStamp();
                        fromtime.time = stime;
                        fromtime.date = sdate;
                        totime = new TTimeStamp();
                        totime.time = etime;
                        totime.date = edate;
                        result = AddChapterEx(num, time, wait, kind, week, ref fromtime, ref totime);
                        break;
                        #endregion
                    case "LED_AddRegion":
                        #region=============================
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        border = System.Convert.ToInt32(p6);
                        result = AddRegion(num, left, top, width, height, border);
                        #endregion
                        break;
                    case "LED_AddLeaf":
                        #region=============================
                        num = System.Convert.ToUInt16(p1);
                        time = System.Convert.ToUInt32(p2);
                        switch ((string)p3)
                        {
                            case "WAIT_CHILD":
                                wait = WAIT_CHILD;
                                break;
                            case "WAIT_USE_TIME":
                                wait = WAIT_USE_TIME;
                                break;
                            default:
                                wait = WAIT_CHILD;
                                break;
                        }
                        result = AddLeaf(num, time, wait);
                        break;
                        #endregion
                    case "LED_AddDateTime":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        fontname = System.Convert.ToString(p8);
                        fontsize = System.Convert.ToInt32(p9);
                        fontcolor = System.Convert.ToInt32(p10);
                        fontstyle = GetFontStyle((string)p11);
                        year_offset = System.Convert.ToInt32(p12);
                        month_offset = System.Convert.ToInt32(p13);
                        day_offset = System.Convert.ToInt32(p14);
                        sec_offset = System.Convert.ToInt32(p15);
                        format = System.Convert.ToString(p16);
                        result = AddDateTime(num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle, year_offset, month_offset, day_offset, sec_offset, format);

                        break;
                        #endregion
                    case "LED_AddDateTimeEx":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        vertical = System.Convert.ToInt32(p8);
                        fontname = System.Convert.ToString(p9);
                        fontsize = System.Convert.ToInt32(p10);
                        fontcolor = System.Convert.ToInt32(p11);
                        fontstyle = GetFontStyle((string)p12);
                        year_offset = System.Convert.ToInt32(p13);
                        month_offset = System.Convert.ToInt32(p14);
                        day_offset = System.Convert.ToInt32(p15);
                        sec_offset = System.Convert.ToInt32(p16);
                        format = System.Convert.ToString(p17);
                        result = AddDateTimeEx(num, left, top, width, height, transparent, border, vertical, fontname, fontsize, fontcolor, fontstyle, year_offset, month_offset, day_offset, sec_offset, format);
                        break;
                        #endregion
                    case "LED_AddCampaignEx":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        vertical = System.Convert.ToInt32(p8);
                        fontname = System.Convert.ToString(p9);
                        fontsize = System.Convert.ToInt32(p10);
                        fontcolor = System.Convert.ToInt32(p11);
                        fontstyle = GetFontStyle((string)p12);
                        format = System.Convert.ToString(p13);
                        year_offset = System.Convert.ToInt32(p13);
                        month_offset = System.Convert.ToInt32(p14);
                        day_offset = System.Convert.ToInt32(p15);
                        sec_offset = System.Convert.ToInt32(p16);
                        btime = System.Convert.ToInt32(p17);
                        bdate = System.Convert.ToInt32(p18);
                        stime = System.Convert.ToInt32(p19);
                        sdate = System.Convert.ToInt32(p20);
                        etime = System.Convert.ToInt32(p21);
                        edate = System.Convert.ToInt32(p22);
                        step = System.Convert.ToInt32(p23);
                        basetime = new TTimeStamp();
                        basetime.time = btime;
                        basetime.date = bdate;
                        fromtime = new TTimeStamp();
                        fromtime.time = stime;
                        fromtime.date = sdate;
                        totime = new TTimeStamp();
                        totime.time = etime;
                        totime.date = edate;
                        result = AddCampaignEx(num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle, format, ref basetime, ref fromtime, ref totime, step);
                        break;
                        #endregion
                    case "LED_AddCounter":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        countertype = System.Convert.ToInt32(p8);
                        int lformat = System.Convert.ToInt32(p9);
                        fontname = System.Convert.ToString(p10);
                        fontsize = System.Convert.ToInt32(p11);
                        fontcolor = System.Convert.ToInt32(p12);
                        fontstyle = GetFontStyle((string)p13);
                        btime = System.Convert.ToInt32(p14);
                        bdate = System.Convert.ToInt32(p15);
                        basetime = new TTimeStamp();
                        basetime.time = btime;
                        result = AddCounter(num, left, top, width, height, transparent, border, countertype, lformat, fontname, fontsize, fontcolor, fontstyle, ref basetime);
                        break;
                        #endregion
                    case "LED_AddClock":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        offset = System.Convert.ToInt32(p8);
                        bkcolor = System.Convert.ToUInt32(p9);
                        bordercolor = System.Convert.ToUInt32(p10);
                        borderwidth = System.Convert.ToUInt32(p11);
                        bordershape = System.Convert.ToInt32(p12);
                        dotradius = System.Convert.ToInt32(p13);
                        adotwidth = System.Convert.ToInt32(p14);
                        adotcolor = System.Convert.ToUInt32(p15);
                        bdotwidth = System.Convert.ToInt32(p15);
                        bdotcolor = System.Convert.ToUInt32(p16);
                        hourwidth = System.Convert.ToInt32(p17);
                        hourcolor = System.Convert.ToUInt32(p18);
                        minutewidth = System.Convert.ToInt32(p19);
                        minutecolor = System.Convert.ToUInt32(p20);
                        secondwidth = System.Convert.ToInt32(p21);
                        secondcolor = System.Convert.ToUInt32(p22);
                        result = AddClock(num, left, top, width, height, transparent, border, offset, bkcolor, bordercolor, borderwidth, bordershape, dotradius, adotwidth, adotcolor, bdotwidth, bdotcolor,
           hourwidth, hourcolor, minutewidth, minutecolor, secondwidth, secondcolor);
                        #endregion
                        break;
                    case "LED_AddClockEx2":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        vertical = System.Convert.ToInt32(p8);
                        offset = System.Convert.ToInt32(p9);
                        bkcolor = System.Convert.ToUInt32(p10);
                        bordercolor = System.Convert.ToUInt32(p11);
                        borderwidth = System.Convert.ToUInt32(p12);

                        bordershape = GetBorderShape((string)p13);
                        dotradius = System.Convert.ToInt32(p14);
                        adotwidth = System.Convert.ToInt32(p15);
                        adotcolor = System.Convert.ToUInt32(p16);
                        bdotwidth = System.Convert.ToInt32(p17);
                        bdotcolor = System.Convert.ToUInt32(p18);
                        cdotvisible = System.Convert.ToUInt32(p19);
                        cdotwidth = System.Convert.ToInt32(p20);
                        cdotcolor = System.Convert.ToUInt32(p21);
                        hourwidth = System.Convert.ToInt32(p22);
                        hourcolor = System.Convert.ToUInt32(p23);
                        minutewidth = System.Convert.ToInt32(p24);
                        minutecolor = System.Convert.ToUInt32(p25);
                        secondwidth = System.Convert.ToInt32(p26);
                        secondcolor = System.Convert.ToUInt32(p27);
                        result = AddClockEx2(num, left, top, width, height, transparent, border, vertical, offset, bkcolor, bordercolor, borderwidth, bordershape, dotradius, adotwidth,
                            adotcolor, bdotwidth, bdotcolor, cdotvisible, cdotwidth, cdotcolor, hourwidth, hourcolor, minutewidth, minutecolor, secondwidth, secondcolor);
                        #endregion
                        break;
                    case "LED_AddMovie":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        filename = System.Convert.ToString(p8);
                        filename = GetPictureFile(filename);
                        stretch = System.Convert.ToInt32(p9);
                        result = AddMovie(num, left, top, width, height, transparent, border, filename, stretch);
                        #endregion
                        break;
                    case "LED_AddWindows":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        result = AddWindows(num, left, top, width, height, transparent, border);
                        #endregion
                        break;
                    case "LED_AddChildWindow":
                        #region==================
                        num = System.Convert.ToUInt16(p1);
                        dc = System.Convert.ToUInt32(p2);
                        width = System.Convert.ToInt32(p2);
                        height = System.Convert.ToInt32(p3);
                        alignment = System.Convert.ToInt32(p4);
                        inmethod = System.Convert.ToInt32(p5);
                        inspeed = System.Convert.ToInt32(p6);
                        outmethod = System.Convert.ToInt32(p7);
                        outspeed = System.Convert.ToInt32(p8);
                        stopmethod = System.Convert.ToInt32(p9);
                        stopspeed = System.Convert.ToInt32(p10);
                        stoptime = System.Convert.ToInt32(p11);
                        result = AddChildWindow(num, dc, width, height, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddChildPicture":
                        #region==============

                        num = System.Convert.ToUInt16(p1);
                        filename = System.Convert.ToString(p2);
                        width = System.Convert.ToInt32(p3);
                        height = System.Convert.ToInt32(p4);
                        alignment = System.Convert.ToInt32(p5);
                        inmethod = System.Convert.ToInt32(p6);
                        inspeed = System.Convert.ToInt32(p7);
                        outmethod = System.Convert.ToInt32(p8);
                        outspeed = System.Convert.ToInt32(p9);
                        stopmethod = System.Convert.ToInt32(p10);
                        stopspeed = System.Convert.ToInt32(p11);
                        stoptime = System.Convert.ToInt32(p12);
                        result = AddChildPicture(num, filename, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddChildText":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        text = System.Convert.ToString(p2);
                        fontname = System.Convert.ToString(p3);
                        fontsize = System.Convert.ToInt32(p4);
                        fontcolor = System.Convert.ToInt32(p5);
                        fontstyle = GetFontStyle((string)p6);
                        wordwrap = System.Convert.ToInt32(p7);
                        alignment = System.Convert.ToInt32(p8);

                        inmethod = System.Convert.ToInt32(p9);
                        inspeed = System.Convert.ToInt32(p10);
                        outmethod = System.Convert.ToInt32(p11);
                        outspeed = System.Convert.ToInt32(p12);
                        stopmethod = System.Convert.ToInt32(p13);
                        stopspeed = System.Convert.ToInt32(p14);
                        stoptime = System.Convert.ToInt32(p15);
                        result = AddChildText(num, text, fontname, fontsize, fontcolor, fontstyle, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddChildTextEx":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        text = System.Convert.ToString(p2);
                        fontname = System.Convert.ToString(p3);
                        fontsize = System.Convert.ToInt32(p4);
                        fontcolor = System.Convert.ToInt32(p5);
                        fontstyle = GetFontStyle((string)p6);
                        autofitsize = System.Convert.ToInt32(p7);
                        wordwrap = System.Convert.ToInt32(p8);
                        vertical = System.Convert.ToInt32(p9);
                        alignment = System.Convert.ToInt32(p10);
                        verticalspace = System.Convert.ToInt32(p11);
                        horizontalfit = System.Convert.ToInt32(p12);
                        inmethod = System.Convert.ToInt32(p13);
                        inspeed = System.Convert.ToInt32(p14);
                        outmethod = System.Convert.ToInt32(p15);
                        outspeed = System.Convert.ToInt32(p16);
                        stopmethod = System.Convert.ToInt32(p17);
                        stopspeed = System.Convert.ToInt32(p18);
                        stoptime = System.Convert.ToInt32(p19);
                        result = AddChildTextEx(num, text, fontname, fontsize, fontcolor, fontstyle, autofitsize, wordwrap, vertical, alignment, verticalspace, horizontalfit,
            inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddStrings":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p6);
                        result = AddStrings(num, left, top, width, height, transparent, border);
                        #endregion
                        break;
                    case "LED_AddChildString":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        text = System.Convert.ToString(p2);
                        fontset = System.Convert.ToInt32(p3);
                        color = System.Convert.ToInt32(p4);
                        inmethod = System.Convert.ToInt32(p5);
                        inspeed = System.Convert.ToInt32(p6);
                        outmethod = System.Convert.ToInt32(p7);
                        outspeed = System.Convert.ToInt32(p8);
                        stopmethod = System.Convert.ToInt32(p9);
                        stopspeed = System.Convert.ToInt32(p10);
                        stoptime = System.Convert.ToInt32(p11);
                        result = AddChildString(num, text, fontset, color, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddWindow":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        szBmpFile = System.Convert.ToString(p8);
                        dc = GetPictureHandle(szBmpFile);
                        src_width = System.Convert.ToInt32(p9);
                        src_height = System.Convert.ToInt32(p10);
                        alignment = System.Convert.ToInt32(p11);
                        inmethod = System.Convert.ToInt32(p12);
                        inspeed = System.Convert.ToInt32(p13);
                        outmethod = System.Convert.ToInt32(p14);
                        outspeed = System.Convert.ToInt32(p15);
                        stopmethod = System.Convert.ToInt32(p16);
                        stopspeed = System.Convert.ToInt32(p17);
                        stoptime = System.Convert.ToInt32(p18);
                        result = AddWindow(num, left, top, width, height, transparent, border, dc, src_width, src_height, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddPicture":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        filename = System.Convert.ToString(p8);
                        filename = GetPictureFile(filename);
                        alignment = System.Convert.ToInt32(p9);
                        inmethod = System.Convert.ToInt32(p10);
                        inspeed = System.Convert.ToInt32(p11);
                        outmethod = System.Convert.ToInt32(p12);
                        outspeed = System.Convert.ToInt32(p13);
                        stopmethod = System.Convert.ToInt32(p14);
                        stopspeed = System.Convert.ToInt32(p15);
                        stoptime = System.Convert.ToInt32(p16);
                        result = AddPicture(num, left, top, width, height, transparent, border, filename, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddTable":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);


                        profile = System.Convert.ToString(p7);
                        content = System.Convert.ToString(p8);

                        inmethod = System.Convert.ToInt32(p9);
                        inspeed = System.Convert.ToInt32(p10);
                        outmethod = System.Convert.ToInt32(p11);
                        outspeed = System.Convert.ToInt32(p12);
                        stopmethod = System.Convert.ToInt32(p13);
                        stopspeed = System.Convert.ToInt32(p14);
                        stoptime = System.Convert.ToInt32(p15);
                        result = Parse2(AddTable(num, left, top, width, height, transparent, profile, content, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime));
                        #endregion
                        break;
                    case "LED_AddText":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        text = System.Convert.ToString(p8);
                        fontname = System.Convert.ToString(p9);
                        fontsize = System.Convert.ToInt32(p10);
                        fontcolor = System.Convert.ToInt32(p11);
                        fontstyle = GetFontStyle((string)p12);
                        wordwrap = System.Convert.ToInt32(p13);
                        alignment = System.Convert.ToInt32(p14);
                        inmethod = System.Convert.ToInt32(p15);
                        inspeed = System.Convert.ToInt32(p16);
                        outmethod = System.Convert.ToInt32(p17);
                        outspeed = System.Convert.ToInt32(p18);
                        stopmethod = System.Convert.ToInt32(p19);
                        stopspeed = System.Convert.ToInt32(p20);
                        stoptime = System.Convert.ToInt32(p21);
                        result = AddText(num, left, top, width, height, transparent, border, text, fontname, fontsize, fontcolor, fontstyle, wordwrap, alignment, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddTextEx3":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        flag = System.Convert.ToInt32(p7);
                        text = System.Convert.ToString(p8);
                        fontname = System.Convert.ToString(p9);
                        fontsize = System.Convert.ToInt32(p10);
                        fontcolor = System.Convert.ToInt32(p11);
                        fontstyle = GetFontStyle((string)p12);
                        Int32 bkgcolor = System.Convert.ToInt32(p13);
                        autofitsize = System.Convert.ToInt32(p14);
                        wordwrap = System.Convert.ToInt32(p15);
                        vertical = System.Convert.ToInt32(p16);
                        alignment = System.Convert.ToInt32(p17);
                        verticalspace = System.Convert.ToInt32(p18);
                        horizontalfit = System.Convert.ToInt32(p19);
                        inmethod = System.Convert.ToInt32(p20);
                        inspeed = System.Convert.ToInt32(p21);
                        outmethod = System.Convert.ToInt32(p22);
                        outspeed = System.Convert.ToInt32(p23);
                        stopmethod = System.Convert.ToInt32(p24);
                        stopspeed = System.Convert.ToInt32(p25);
                        stoptime = System.Convert.ToInt32(p26);
                        result = AddTextEx3(num, left, top, width, height, transparent, flag,
                            text, fontname, fontsize, fontcolor, fontstyle, bkgcolor, autofitsize, wordwrap, vertical, alignment, verticalspace, horizontalfit, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddString":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        text = System.Convert.ToString(p2);
                        fontset = System.Convert.ToInt32(p3);
                        color = System.Convert.ToInt32(p4);
                        inmethod = System.Convert.ToInt32(p5);
                        inspeed = System.Convert.ToInt32(p6);
                        outmethod = System.Convert.ToInt32(p7);
                        outspeed = System.Convert.ToInt32(p8);
                        stopmethod = System.Convert.ToInt32(p9);
                        stopspeed = System.Convert.ToInt32(p10);
                        stoptime = System.Convert.ToInt32(p11);
                        result = AddString(num, left, top, width, height, transparent, border, text, fontset, color, inmethod, inspeed, outmethod, outspeed, stopmethod, stopspeed, stoptime);
                        #endregion
                        break;
                    case "LED_AddTemperature":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        fontname = System.Convert.ToString(p8);
                        fontsize = System.Convert.ToInt32(p9);
                        fontcolor = System.Convert.ToInt32(p10);
                        fontstyle = GetFontStyle((string)p11);
                        result = AddTemperature(num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle);
                        #endregion
                        break;
                    case "LED_AddHumidity":
                        #region==============
                        num = System.Convert.ToUInt16(p1);
                        left = System.Convert.ToInt32(p2);
                        top = System.Convert.ToInt32(p3);
                        width = System.Convert.ToInt32(p4);
                        height = System.Convert.ToInt32(p5);
                        transparent = System.Convert.ToInt32(p6);
                        border = System.Convert.ToInt32(p7);
                        fontname = System.Convert.ToString(p8);
                        fontsize = System.Convert.ToInt32(p9);
                        fontcolor = System.Convert.ToInt32(p10);
                        fontstyle = GetFontStyle((string)p11);
                        result = AddHumidity(num, left, top, width, height, transparent, border, fontname, fontsize, fontcolor, fontstyle);
                        #endregion
                        break;
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                result = 0;
            }
            return result;
        }
        private string GetPictureFile(string szBmp)
        {
            string file = "D:\\SXDFile\\" + szBmp;
            if (!System.IO.File.Exists(file))
            {
                file = "D:\\SXDFile\\FileNotExist.jpg";
            }
            return file;
        }
        private uint GetPictureHandle(string szBmp)
        {
            string file = "D:\\SXDFile\\" + szBmp;
            if (!System.IO.File.Exists(file))
            {
                file = "D:\\SXDFile\\FileNotExist.jpg";
            }
            Graphics G;
            System.Drawing.Image imageFile = System.Drawing.Image.FromFile(file);

            G = Graphics.FromImage(imageFile);
            return (uint)G.GetHdc();
        }
        private Int32 GetFontStyle(string ft)
        {
            Int32 result = 0;
            switch ((string)ft)
            {
                case "WFS_NONE":
                    result = WFS_NONE;
                    break;
                case "WFS_BOLD":
                    result = WFS_BOLD;
                    break;
                case "WFS_ITALIC":
                    result = WFS_ITALIC;
                    break;
                case "WFS_UNDERLINE":
                    result = WFS_UNDERLINE;
                    break;
                case "WFS_STRIKEOUT":
                    result = WFS_STRIKEOUT;
                    break;
            }
            return result;
        }
        private Int32 GetSurvive(string str)
        {
            Int32 survive = 1;
            switch ((string)str)
            {
                case "SURVIVE_ALWAYS":
                    survive = SURVIVE_ALWAYS;
                    break;
                default:
                    survive = SURVIVE_ALWAYS;
                    break;
            }
            return survive;
        }
        private Int32 GetColorMode(string str)
        {
            Int32 ColorMode = 1;
            switch (str)
            {
                case "COLOR_MODE_MONO":
                    ColorMode = COLOR_MODE_MONO;
                    break;
                case "COLOR_MODE_DOUBLE":
                    ColorMode = COLOR_MODE_DOUBLE;
                    break;
                case "COLOR_MODE_FULL_16BIT":
                    ColorMode = COLOR_MODE_FULL_16BIT;
                    break;
                case "COLOR_MODE_FULL_32BIT":
                    ColorMode = COLOR_MODE_FULL_32BIT;
                    break;
                default:
                    ColorMode = COLOR_MODE_MONO;
                    break;
            }
            return ColorMode;
        }
        private Int32 GetActoonMode(string str)
        {
            Int32 ActionMode = 1;
            switch (str)
            {
                case "ACTMODE_INSERT":
                    ActionMode = ACTMODE_INSERT;
                    break;
                case "ACTMODE_REPLACE":
                    ActionMode = ACTMODE_REPLACE;
                    break;
                default:
                    ActionMode = ACTMODE_INSERT;
                    break;
            }
            return ActionMode;
        }
        private Int32 GetRootType(string str)
        {
            Int32 RootType = 1;
            switch (str)
            {
                case "ROOT_UPDATE":
                    RootType = ROOT_UPDATE;
                    break;
                case "ROOT_FONTSET":
                    RootType = ROOT_FONTSET;
                    break;
                case "ROOT_PLAY":
                    RootType = ROOT_PLAY;
                    break;
                case "ROOT_DOWNLOAD":
                    RootType = ROOT_DOWNLOAD;
                    break;
                case "ROOT_PLAY_CHAPTER":
                    RootType = ROOT_PLAY_CHAPTER;
                    break;
                case "ROOT_PLAY_REGION":
                    RootType = ROOT_PLAY_REGION;
                    break;
                case "ROOT_PLAY_LEAF":
                    RootType = ROOT_PLAY_LEAF;
                    break;
                case "ROOT_PLAY_OBJECT":
                    RootType = ROOT_PLAY_OBJECT;
                    break;
                default:
                    RootType = ROOT_PLAY;
                    break;
            }
            return RootType;
        }
        private Int32 GetWaitType(string str)
        {
            Int32 WaitType = 1;
            switch (str)
            { 
                case "WAIT_USE_TIME":
                    WaitType = WAIT_USE_TIME;
                    break;
                case "WAIT_CHILD":
                    WaitType = WAIT_CHILD;
                    break;
                
                
                default:
                    WaitType = WAIT_USE_TIME;
                    break;
            }
            return WaitType;
        }
        private Int32 GetBorderShape(string str)
        {
            Int32 BorderShape = 1;
            switch (str)
            { 
                case "SHAPE_RECTANGLE":
                    BorderShape = SHAPE_RECTANGLE;
                    break;
                case "SHAPE_ROUNDRECT":
                    BorderShape = SHAPE_ROUNDRECT;
                    break;
                case "SHAPE_CIRCLE":
                    BorderShape = SHAPE_CIRCLE;
                    break;
                default:
                    BorderShape = SHAPE_CIRCLE;
                    break;
            }
            return BorderShape;
        }
        
    }
}
